package co.sanduche.services;

import android.content.Context;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

public class EPClient {

	public enum DevPhase {
		/** */
		Development("http://192.168.137.1:9000", "kiidodevpics"),
		/** */
		Staging("http://sanduche.herokuapp.com", "kiidostagingpics"),
		/** */
		Production("http://kiido.herokuapp.com", "kiidouserpics");

		public String server;
		public String bucket;

		DevPhase(String server, String bucket) {
			this.server = server;
			this.bucket = bucket;
		}
	};

	private static DevPhase phase;

	public final static String AUTH_COOKIE = "PLAY_SESSION";

	private static RequestQueue requestQueue;

	public static void config(Context context) {
		requestQueue = Volley.newRequestQueue(context);
	}

	public static <T> void addRequest(Request<T> req) {
		req.setRetryPolicy(new DefaultRetryPolicy(10000, 0,
				DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
		requestQueue.add(req);
	}

	public static void setCookie(String cookie) {

	}

	public static String getAbsoluteUrl(String url) {
		return phase.server + url;
	}

	public static void setDevPhase(DevPhase p) {
		if (phase == null)
			phase = p;
	}

	public static DevPhase getDevPhase() {
		return phase;
	}
}
